Fix wrapt 2.x compatibility: rename module → target in wrap_function_wrapper call - #264
Open
joetanx wants to merge 2 commits into
Open
Fix wrapt 2.x compatibility: rename module → target in wrap_function_wrapper call#264joetanx wants to merge 2 commits into
module → target in wrap_function_wrapper call#264joetanx wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the LangChain observability instrumentor to be compatible with wrapt 2.x by adjusting how wrapt.wrap_function_wrapper() is invoked when wrapping BaseCallbackManager.__init__.
Changes:
- Switches from the removed
module=keyword argument totarget=in thewrap_function_wrappercall.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment on lines
74
to
78
| wrap_function_wrapper( | ||
| module="langchain_core.callbacks", | ||
| target="langchain_core.callbacks", | ||
| name="BaseCallbackManager.__init__", | ||
| wrapper=_BaseCallbackManagerInit(self._tracer), | ||
| ) |
There was a problem hiding this comment.
Unresolving this conversation because Copilot is right here. I don't think having target here is actually compatible with any 1.x version. We'll need to check if using just positional arguments would work without issues
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
CustomLangChainInstrumentor._instrument()callswrapt.wrap_function_wrapper()using themodulekeyword argument, which was [removed in wrapt 2.0](https://github.com/GrahamDumpleton/wrapt/releases/tag/2.0.0) and renamed totarget. This forces downstream consumers to pinwrapt<2, which conflicts with other packages that already requirewrapt>=2.Fix
Use the
targetparameter instead. The new combined-path syntax ("module:qualname") is supported in both wrapt 1.x (≥1.16) and 2.x, so this change is backwards-compatible.Impact
wrapt<2